﻿<UserControl x:Class="Wpf.Explorations.TestApplication.PersonControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:s="clr-namespace:System;assembly=mscorlib"
	xmlns:local="clr-namespace:Wpf.Explorations.TestApplication"
	xmlns:l="clr-namespace:System.Linq;assembly=System.Core">
	<UserControl.Resources>
		<ObjectDataProvider x:Key="Ages" ObjectType="{x:Type l:Enumerable}" MethodName="Range">
			<ObjectDataProvider.MethodParameters>
				<s:Int32>0</s:Int32>
				<s:Int32>100</s:Int32>
			</ObjectDataProvider.MethodParameters>
		</ObjectDataProvider>
		<ObjectDataProvider x:Key="Genders" ObjectType="{x:Type s:Enum}" MethodName="GetValues">
			<ObjectDataProvider.MethodParameters>
				<x:Type TypeName="local:Gender" />
			</ObjectDataProvider.MethodParameters>
		</ObjectDataProvider>
	</UserControl.Resources>
	<Border BorderBrush="Gray" BorderThickness="1" Margin="2">
		<Grid>
			<Grid.Resources>
				<Style TargetType="{x:Type TextBlock}" x:Key="PromptStyle">
					<Setter Property="HorizontalAlignment" Value="Stretch" />
					<Setter Property="VerticalAlignment" Value="Center" />
					<Setter Property="TextAlignment" Value="Right" />
					<Setter Property="Margin" Value="3" />
				</Style>
			</Grid.Resources>
			<Grid.ColumnDefinitions>
				<ColumnDefinition />
				<ColumnDefinition />
			</Grid.ColumnDefinitions>
			<Grid.RowDefinitions>
				<RowDefinition />
				<RowDefinition />
				<RowDefinition />
				<RowDefinition />
			</Grid.RowDefinitions>
			<TextBlock FontWeight="Bold" HorizontalAlignment="Center" Grid.ColumnSpan="2">
				<TextBlock.Text>
					<MultiBinding StringFormat="{}{0} {1}">
						<Binding Path="FirstName" />
						<Binding Path="LastName" />
					</MultiBinding>
				</TextBlock.Text>
			</TextBlock>
			<TextBlock Grid.Row="1" Style="{StaticResource PromptStyle}" Text="Gender:" />
			<ComboBox Grid.Row="1" Grid.Column="1" SelectedItem="{Binding Gender, Mode=TwoWay}" ItemsSource="{Binding Source={StaticResource Genders}}" 
				IsEnabled="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListViewItem}}}"/>
			<TextBlock Grid.Row="2" Style="{StaticResource PromptStyle}" Text="Age:" />
			<ComboBox Grid.Row="2" Grid.Column="1" SelectedItem="{Binding Age, Mode=TwoWay}" ItemsSource="{Binding Source={StaticResource Ages}}" 
				IsEnabled="{Binding IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListViewItem}}}"/>
			<TextBlock Grid.Row="3" Style="{StaticResource PromptStyle}" Text="Category:" />
			<TextBlock Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" Text="{Binding Category}" />
		</Grid>
	</Border>
</UserControl>
